package khh;

import static org.junit.Assert.assertTrue;
import org.junit.Test;

/**
 * Tests that the robot's tracking method correctly returns the minimal amount of degrees that the
 * gun needs to turn to be pointing at the enemy robot.
 * 
 * @author Kylan Hughes
 * @version 1.0
 * 
 */
public class TestKylanTracking {

  double gun;
  double enemy;
  double turn;
  boolean checkTurn;

  /**
   * Gives experimental data to the tracking method from Kylan to test that it returns
   * the correct amount that the gun has to turn in order to be pointing at the enemy.
   */
  @Test
  public void testTracking() {
    // test for when gun's angle is lower than enemy and quickest way is to rotate right.
    gun = 45;
    enemy = 170;
    turn = Kylan.trackEnemyRobot(gun, enemy);
    //Had to do this because PMDs requirement of using
    //assertSame("Check that turn is 125.", turn, 125);
    //would not compile correctly.
    if (turn == 125) {
      checkTurn = true;
    }
    assertTrue("Check that turn is 125.", checkTurn);
    checkTurn = false;
    // test for when gun's angle is lower than enemy but quickest way is to rotate left.
    gun = 150;
    enemy = 350;
    turn = Kylan.trackEnemyRobot(gun, enemy);
    if (turn == -160) {
      checkTurn = true;
    }
    assertTrue("Check that turn is -160.", checkTurn);
    checkTurn = false;
    // test for when gun's angle is higher than enemy and quickest way is to rotate left.
    gun = 170;
    enemy = 45;
    turn = Kylan.trackEnemyRobot(gun, enemy);
    if (turn == -125) {
      checkTurn = true;
    }
    assertTrue("Check that turn is -125.", checkTurn);
    checkTurn = false;
    // test for when gun's angle is higher than enemy and quickest way is to rotate right.
    gun = 350;
    enemy = 150;
    turn = Kylan.trackEnemyRobot(gun, enemy);
    if (turn == 160) {
      checkTurn = true;
    }
    assertTrue("Check that turn is 160.", checkTurn);
    checkTurn = false;
    // test with unusually high numbers, all degrees of circle though so should be valid.
    gun = 10000; // 280
    enemy = 5876; // 116
    turn = Kylan.trackEnemyRobot(gun, enemy);
    if (turn == -164) {
      checkTurn = true;
    }
    assertTrue("Check that turn is -164.", checkTurn);
  }

}
